import http from '@/utils/request'

const API_PREFIX = '/web/bots'

const options = {
  ignoreCancelToken: false
}

export const fetcBotGrid = params =>
  http.get(`${API_PREFIX}/sys/bot/grid-list`, { params }, options)

export const fetchBotList = params =>
  http.post(`${API_PREFIX}/sys/bot/new-card-list`, params, {}, options)

export const setBotSwitch = params =>
  http.put(`${API_PREFIX}/sys/bot/${params.id}/switch`, params)

export const submitCloseMessageReasonsApi = params =>
  http.post(`${API_PREFIX}/sys/bot-close-reason/save`, params)

export const deleteBotInfoApi = params =>
  http.delete(`${API_PREFIX}/sys/bot/${params.id}/delete`, params)

export const fetchBot = params =>
  http.get(`${API_PREFIX}/sys/bot/${params.id}/info`, { params })

export const fetchBotTemplates = params =>
  http.get(`${API_PREFIX}/sys/bot/list-template`, { params })

export const checkBotName = params =>
  http.post(`${API_PREFIX}/sys/bot/checkname`, params)

export const createBot = params =>
  http.post(`${API_PREFIX}/sys/bot/new`, params)

export const updateBot = params =>
  http.put(`${API_PREFIX}/sys/bot/${params.id}/update`, params)
